<template>
  <div class="home" style="text-align:left;">
    <uploadBox @update="getData"></uploadBox>
    
    <h3>图片数据：</h3>
    <imgList :tableData="tableData"></imgList>
  </div>
</template>

<script>
// @ is an alias to /src
import uploadBox from '@/components/upload-box.vue'
import imgList from '@/components/img-list.vue'

export default {
  name: 'HomeView',
  components: {
    uploadBox,
    imgList
  },
  data(){
    return{
      tableData: []
    }
  },
  created(){
    this.getData()
  },
  methods:{
    async getData() {
      const res = await this.$axios.get("/api/getList");
      console.log("getList-res:", res);
      this.tableData=[]
      if (res && res.data && res.data.length) {
        for (let i = 0; i < res.data.length; i++) {
          let one = { url: res.data[i], name: res.data[i] };
          this.tableData.push(one);
        }
      }
    },
  }
}
</script>
